<?php 
class WebSetModel extends Model{
	public $table = 'config';
	
	public function get_all_data($where=NULL){
		return $this->where($where)->all();
	}
	
	/**
	 * 修改配置项
	 */
	public function update_config(){
		//执行数据库修改
	   foreach (Q('post.') as $k => $v) {
	   		$this->where(array('coid'=>$k))->save(array('value'=>$v));
	   }
	   //修改文件webConfig.php
	   $data = array();
	   foreach ($this->all() as $v) {
	   		$data[$v['name']] = $v['value'];
	   }
	   $data = var_export($data,true);
	  $str = <<<str
<?php
if (!defined("HDPHP_PATH"))exit('No direct script access allowed');
//更多配置请查看hdphp/Config/config.php
return {$data};
str;
	file_put_contents(APP_CONFIG_PATH . 'webConfig.php', $str);
	  	
	   
	}
}
 
 
 
 
 
 
 
 
 
 
 
 